import requset from "../utils/requset"

// 登录接口
export let Login = (data) => {
    return requset({
        url: "/login",
        method: "post",
        data
    })
}

// 导航页面log区域接口
export let log = () => {
    return requset({
        url: "/home/category/head",
        method: "get",
    })
}


//购物车数据
export let jumpShoop = () => {
    return requset({
        url: "/member/cart",
        method: "get",
    })
}
//购物车数量
export let jumpShoopNum = () => {
    return requset({
        url: "/member/cart/count",
        method: "get",
    })
}

// 修改购物车
export let xiu = (skuId, count, select = null) => {
    // console.log(count);
    return requset({
        url: "/member/cart/" + skuId,
        method: "put",
        data: {
            count: count,
            selected: select
        }
    })
}
//删除购物车数据
export let deleteData = (ids, clearAll, clearInvalid) => {
    return requset({
        url: "/member/cart",
        method: "DELETE",
        data: {
            ids,
            clearAll,
            clearInvalid
        }
    })
}

//购物车全选
export const qvanxvanBtn = (ids, selected) => {
    return requset({
        url: "/member/cart/selected",
        method: "PUT",
        data: {
            ids,
            selected
        }
    })
}

//购物车添加地址
export const addDizhi = (receiver, contact, provinceCode, cityCode, countyCode, address, postalCode, addressTags, isDefault) => {
    return requset({
        url: "/member/address",
        method: "POST",
        data: {
            receiver,
            contact,
            provinceCode,
            cityCode,
            countyCode,
            address,
            postalCode,
            addressTags,
            isDefault
        }
    })
}

//购物车切换收货地址
export const qiehuan = (receiver, contact, provinceCode, cityCode, countyCode, address, postalCode, addressTags, isDefault) => {
    return requset({
        url: "/member/address",
        method: "GET",
        params: {
            receiver,
            contact,
            provinceCode,
            cityCode,
            countyCode,
            address,
            postalCode,
            addressTags,
            isDefault
        }
    })
}

//更新收货地址
export const gengxin = (ids, receiver, contact, provinceCode, cityCode, countyCode, address, postalCode, addressTags, isDefault) => {
    return requset({
        url: "/member/address/" + ids,
        method: "PUT",
        data: {
            receiver,
            contact,
            provinceCode,
            cityCode,
            countyCode,
            address,
            postalCode,
            addressTags,
            isDefault
        }
    })
}

//订单数据
export let OrderData = (page = 1, orderState = 0) => {
    return requset({
        url: "/member/order",
        method: "get",
        params: {
            page,
            pageSize: 5,
            orderState
        }
    })
}
//我的订单 取消订单
export let orderCancel = (id, cancelReason) => {
    console.log(cancelReason);
    return requset({
        url: "/member/order/" + id + "/cancel",
        method: "PUT",
        data: {
            cancelReason
        }
    })
}
//我的订单  查看详情
export let DetailsData = (id) => {
    return requset({
        url: "/member/order/" + id,
    })
}

export let aaaa = () => {
    return requset({
        url: "/member/cart",
    })
}

//导航栏二级路由接口
export let navGtion = (a) => {
    return requset({
        url: "/category?id=" + a,
        methods: "get"
    })
}



export let ThreeCate = (newId) => {
    return requset({
        url: "category/sub/filter?id=" + newId,
    })
}
// 首页轮播图接口
export let banner = () => {
    return requset({
        url: "home/banner",
        method: "get",
    })
}

//我的订单 物流信息
export let logisticsData = (id) => {
    return requset({
        url: "/member/order/" + id + "/logistics",
        method: "get",
    })
}
//我的订单 删除订单
export let deleOrder = (ids) => {
    return requset({
        url: "/member/order",
        method: "DELETE",
        data: {
            ids
        }
    })
}
//个人中心 我的足迹

export let mybrowse = () => {
    return requset({
        url: "/member/browseHistory",
        method: "get",
        params: {
            page: 1,
            pagSize: 4
        }
    })
}
//个人中心 轮播图
export let myrelevant = () => {
    return requset({
        url: "/goods/relevant",
        method: "get",
        params: {
            limit: 16
        }
    })
}

//提交订单
// export const tijiao = (goods, skuId,count,addressId,deliveryTimeType,payType,payChannel) => {
//      return requset({
//         url:" /member/order",
//         method:"POST",
//         data:{
//             goods,
//             skuId,
//             count,
//             addressId,
//             deliveryTimeType,
//             payType,
//             payChannel
//         }
//      })
// }




// 首页新鲜好物接口
export let fresh = () => {
    return requset({
        url: "/home/new",
        method: "get",
    })
}


export let Content = (pageNumber, a) => {
    return requset({
        url: "category/goods/temporary",
        method: "POST",
        data: {
            page: 1,
            categoryId: a,
            pageSize: pageNumber
        }
    })
}


// 首页人气推荐接口
export let panel = () => {
    return requset({
        url: "/home/hot",
        method: "get",
    })
}

// 首页热门品牌接口
export let boxs = () => {
    return requset({
        url: "/home/brand",
        method: "get",
    })
}


//首页产品区块接口
export let goods = () => {
    return requset({
        url: "/home/goods",
        method: "get",
    })
}

// 首页最新专题接口
export let tit = () => {
    return requset({
        url: "/home/special",
        method: "get",
    })
}

